package com.xiaoke.liantongdemo.animation;


import android.content.Context;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class AnimationView extends ImageView {
	
	private int position;

	public AnimationView(Context context, int resourceId) {
		super(context);
		setImageResource(resourceId);
	}
	
	public void animateTo(int positionNew){
		Animation animation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, 
				position, TranslateAnimation.RELATIVE_TO_SELF, positionNew, 0, 0, 0, 0);
		animation.setDuration(1000);
		animation.setFillAfter(true);
		startAnimation(animation);
		position = positionNew;
	}
	
	

}
